Python | Add similar value multiple times in list
Adding a single value in list is quite generic and easy. But to add that value more than one time, generally, a loop is used to execute this task. Having shorter tricks to perform this can be handy. Let’s discuss certain ways in which this can be done....
read more
Python – Filter tuple with all same elements
Given List of tuples, filter tuples that have same values....
read more
Python program to find number of m contiguous elements of a List with a given sum
Given a list ‘L’, a sum ‘S’ and number of elements to take at a time ‘m’. The task is to find how many ways sum s can be found by adding any m contiguous elements. Examples:...
read more
Python | K elements Slicing
We often come to the situations in which we need to extract initial K elements of list. This particular problem occurs when we need to optimize memory. This has its application in the day-day programming when sometimes we require to get all the lists of similar size. Let’s discuss certain ways in which this task can be performed. Method #1 : Using len() + list slicing List slicing can perform this particular task in which we just slice the first K elements to be in the list and hence removing the remaining elements, freeing memory....
read more
Python – Consecutive Tuple difference
Given List of tuples, find index-wise absolute difference of consecutive tuples....
read more
Python – Maximum column values in mixed length 2D List
The usual list of list, unlike conventional C type Matrix, can allow the nested list of lists with variable lengths, and when we require the maximizations of its columns, the uneven length of rows may lead to some elements in that elements to be absent and if not handled correctly, may throw an exception. Let’s discuss certain ways in which this problem can be performed in an error-free manner....
read more
Python program to remove each y occurrence before x in List
Given a list, remove all the occurrence of y before element x in list....
read more
Python | Printing list vertically
Printing the list has been dealt many times. But sometimes we need a different format to get the output of list. This also has application in getting a transpose of matrix. Printing list vertically also has application in web development. Lets discuss certain ways in which this task can be achieved....
read more
Python – Split heterogeneous type list
Sometimes, we might be working with many data types and in these instances, we can have a problem in which list that we receive might be having elements from different data types. Let’s discuss certain ways in which this task can be performed....
read more
Python | Multiply each element in a sublist by its index
Given a list of lists, the task is to multiply each element in a sublist by its index and return a summed list. Given below are a few methods to solve the problem....
read more
Python – Extract Percentages from String
Given a String, extract all the numbers that are percentages....
read more
Python | Convert numeric String to integers in mixed List
Sometimes, while working with data, we can have a problem in which we receive mixed data and need to convert the integer elements in form of strings to integers. This kind of operation might be required in data preprocessing step. Let’s discuss certain ways in which this task can be performed....
read more